#ifndef __I_CROSSFIRE_SCENENODE_H_
#define __I_CROSSFIRE_SCENENODE_H_

#include "IObject.h"
#include <list>
//For math classes
#include <d3dx9.h>


namespace cfe
{

class ICF_SceneManager;

class ICF_SceneNode : public ICF_Object
{
public:
	//get parent node
	const ICF_SceneNode* getParent() const
	{
		return m_pParent;
	};
	//copy from name to m_name
	void setName(char* name)
	{
		m_name = new char[strlen(name)];
		strcpy(m_name, name);
		//or set name pointer
		//m_name = name;
	};
	//get name this node
	const char* getName() const
	{
		return m_name;
	};
	//add children object
	bool addChildren(ICF_SceneNode* node)
	{
		if(!node)
			return false;
		node->m_pParent = this;
		node->m_pMng = m_pMng;

		m_lChildrens.push_back(node);
		return true;
	};
	//Remove all childrens objects
	void RemoveAll()
	{
		ICF_SceneNode* node = NULL;
		std::list<ICF_SceneNode*>::iterator iter = m_lChildrens.begin();
		while(iter != m_lChildrens.end())
		{
			node = (ICF_SceneNode*)*iter;
			node->RemoveAll();
			node->Destroy();
			node = NULL;
			iter++;
		}
		m_lChildrens.clear();
	};
	//render this
	virtual void render() = 0;
	//Render this and childrens objects
	void renderAll()
	{
		render();

		ICF_SceneNode* node = NULL;
		std::list<ICF_SceneNode*>::iterator iter = m_lChildrens.begin();
		while(iter != m_lChildrens.end())
		{
			node = (ICF_SceneNode*)*iter;
			node->renderAll();
			iter++;
		}	
	};

	//void setSceneManager(ICF_SceneManager* mng)
	//{
	//	m_pMng = mng;
	//}

	ICF_SceneManager* getSceneManager() const
	{
		return m_pMng;
	}

	virtual void Destroy() = 0;
protected:
	//BoundingBox node///
	char* m_name;
	ICF_SceneNode* m_pParent;
	ICF_SceneManager* m_pMng;
	std::list<ICF_SceneNode*> m_lChildrens;
	bool visible;
};

};

#endif